package com.chris.cc.gateway.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import tk.mybatis.spring.mapper.MapperScannerConfigurer;

import java.util.Properties;

@Configuration
public class MyBatisConfiguration {

    @Bean
    public static MapperScannerConfigurer mapperScannerConfigurer() {
        MapperScannerConfigurer configurer = new MapperScannerConfigurer();
        configurer.setSqlSessionFactoryBeanName("sqlSessionFactory");
        // mapper package name
        String mapperPackageName = MyBatisConfiguration.class.getPackage().getName().replace(".config", ".mapper");
        configurer.setBasePackage(mapperPackageName);
        Properties props = new Properties();
        props.setProperty("mappers", "tk.mybatis.mapper.common.Mapper");
        configurer.setProperties(props);
        return configurer;
    }
}
